package com.jin.jpa.wrapper;

import javax.persistence.criteria.*;

/**
 * @Author: yuanxiuyao
 * @Date: 2024/1/4 15:13
 * @PackageName: org.example.jpa.wrapper.expression
 * @Version 1.0
 */
public class LambdaWrapperContext<T> {

    private CriteriaQuery<?> criteriaQuery;

    private CriteriaUpdate<?> criteriaUpdate;

    private CriteriaDelete<?> criteriaDelete;

    private CriteriaBuilder criteriaBuilder;

    private Root<T> root;

    private LambdaWrapperContext(){}

    public LambdaWrapperContext(CriteriaBuilder criteriaBuilder, CriteriaQuery<?> criteriaQuery, Root<T> root){
        this.criteriaBuilder = criteriaBuilder;
        this.criteriaQuery = criteriaQuery;
        this.root = root;
    }

    public LambdaWrapperContext(CriteriaBuilder criteriaBuilder, CriteriaUpdate<?> criteriaUpdate, Root<T> root){
        this.criteriaBuilder = criteriaBuilder;
        this.criteriaUpdate = criteriaUpdate;
        this.root = root;
    }

    public LambdaWrapperContext(CriteriaBuilder criteriaBuilder, CriteriaDelete<?> criteriaDelete, Root<T> root){
        this.criteriaBuilder = criteriaBuilder;
        this.criteriaDelete = criteriaDelete;
        this.root = root;
    }

    public static <T> LambdaWrapperContext<T> of(CriteriaBuilder criteriaBuilder, CriteriaQuery<?> criteriaQuery, Root<T> root){
        return new LambdaWrapperContext<T>(criteriaBuilder, criteriaQuery, root);
    }

    public static <T> LambdaWrapperContext<T> of(CriteriaBuilder criteriaBuilder, CriteriaUpdate<?> criteriaUpdate, Root<T> root){
        return new LambdaWrapperContext<T>(criteriaBuilder, criteriaUpdate, root);
    }

    public static <T> LambdaWrapperContext<T> of(CriteriaBuilder criteriaBuilder, CriteriaDelete<?> criteriaDelete, Root<T> root){
        return new LambdaWrapperContext<T>(criteriaBuilder, criteriaDelete, root);
    }

    public CriteriaQuery<?> getCriteriaQuery() {
        return criteriaQuery;
    }

    public CriteriaUpdate<?> getCriteriaUpdate() {
        return criteriaUpdate;
    }

    public CriteriaDelete<?> getCriteriaDelete() {
        return criteriaDelete;
    }

    public CriteriaBuilder getCriteriaBuilder() {
        return criteriaBuilder;
    }

    public Root<T> getRoot() {
        return root;
    }

}
